#include <iostream>

#include <device_service.pb.h>
#include <grpcpp/grpcpp.h>

int main(int, char **) {
  simpleservice::HelloRequest request;
  request.set_name("hello request");
  simpleservice::HelloReply reply;
  reply.set_message("hello reply");
  std::string requestStr, replyStr;
  bool ok1 = request.SerializeToString(&requestStr); // 得到的string是一个tlv格式的类型
  bool ok2 = reply.SerializeToString(&replyStr);
  auto print = [](const std::string &str) {
    for (unsigned char c : str) {
      printf("%02x ",c);
    }
    printf("\n");
  };
  if (ok1) {
    print(requestStr);
  }
  if (ok2) {
    print(replyStr);
  }
  std::getchar();
  std::cout << "Hello, from grpc_demo!\n";
}
